<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>添加&nbsp;|&nbsp;华软图书管理系统</title>
    <link href="asserts/layui/css/layui.css" type="text/css" rel="stylesheet"/>
    <script src="asserts/layui/layui.js"></script>
</head>
<body>
<h2 align="center" style="margin: 35px 0 0 0">添加图书</h2>
<div class="layui-row" style="padding: 15px 0;">
    <div class="layui-col-md4" >
        <div style="width: 10px; height: 10px;"></div>
    </div>
    <div class="layui-col-md4 layui-anim layui-anim-upbit">
        <form class="layui-form layui-form-pane" action="add.do" method="post"
              enctype="multipart/form-data">
            <div class="layui-form-item">
                <label class="layui-form-label">书名</label>
                <div class="layui-input-block">
                    <input id="name" type="text" name="name" value="" lay-verify="required" placeholder="输入书本名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">作者</label>
                <div class="layui-input-block">
                    <input id="author" type="text" name="author" lay-verify="required" placeholder="输入作者" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">ISBN</label>
                <div class="layui-input-block">
                    <input id="isbn" type="text" name="isbn" lay-verify="required" placeholder="输入ISBN号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">出版社</label>
                <div class="layui-input-block">
                    <input id="press" type="text" name="press" lay-verify="required" placeholder="输入出版社" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <!-- 考虑JS验证数据 -->
                <label class="layui-form-label">库存</label>
                <div class="layui-input-block">
                    <input id="quantity" type="text" name="quantity" lay-verify="required" placeholder="输入数量" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">书本简介</label>
                <div class="layui-input-block">
                    <textarea id="information" name="information" placeholder="输入介绍信息" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">上传图片</label>
                <div class="layui-input-block">
                    <!-- 为了不绑定到Books对象上，所以命名区别于Books类对应属性 -->
                    <input name="file" type="file" />
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="*">提交</button>
                    <button type="reset" class="layui-btn layui-btn-warm">重置</button>
                    <a href="books.do" class="layui-btn layui-btn-normal">返回</a>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="layui-col-md4" style="background-color: green;">

</div>
<script>
    layui.use(['form'], function () {
        var form = layui.form;
    });
    <#if errorMessage??>
    alert("${errorMessage}");
    </#if>

    <#if book??>
    document.getElementById("name").value = "${book.name}";
    document.getElementById("author").value = "${book.author}";
    document.getElementById("isbn").value = "${book.isbn}";
    document.getElementById("press").value = "${book.press}";
    document.getElementById("quantity").value = "${book.quantity}";
    document.getElementById("information").innerHTML = "${book.information}";
    </#if>

</script>
</body>
</html>